home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / editors / emacs / xemacs / xemacs-1.004 / xemacs-1 / xemacs-19.13 / info / lispref.info-29 < prev    next >
Encoding:
GNU Info File  |  1995-08-31  |  50.5 KB  |  1,202 lines

  1. This is Info file ../../info/lispref.info, produced by Makeinfo-1.63
  2. from the input file lispref.texi.
  3.  
  4.    Edition History:
  5.  
  6.    GNU Emacs Lisp Reference Manual Second Edition (v2.01), May 1993 GNU
  7. Emacs Lisp Reference Manual Further Revised (v2.02), August 1993 Lucid
  8. Emacs Lisp Reference Manual (for 19.10) First Edition, March 1994
  9. XEmacs Lisp Programmer's Manual (for 19.12) Second Edition, April 1995
  10. GNU Emacs Lisp Reference Manual v2.4, June 1995 XEmacs Lisp
  11. Programmer's Manual (for 19.13) Third Edition, July 1995
  12.  
  13.    Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995 Free Software
  14. Foundation, Inc.  Copyright (C) 1994, 1995 Sun Microsystems, Inc.
  15. Copyright (C) 1995 Amdahl Corporation.  Copyright (C) 1995 Ben Wing.
  16.  
  17.    Permission is granted to make and distribute verbatim copies of this
  18. manual provided the copyright notice and this permission notice are
  19. preserved on all copies.
  20.  
  21.    Permission is granted to copy and distribute modified versions of
  22. this manual under the conditions for verbatim copying, provided that the
  23. entire resulting derived work is distributed under the terms of a
  24. permission notice identical to this one.
  25.  
  26.    Permission is granted to copy and distribute translations of this
  27. manual into another language, under the above conditions for modified
  28. versions, except that this permission notice may be stated in a
  29. translation approved by the Foundation.
  30.  
  31.    Permission is granted to copy and distribute modified versions of
  32. this manual under the conditions for verbatim copying, provided also
  33. that the section entitled "GNU General Public License" is included
  34. exactly as in the original, and provided that the entire resulting
  35. derived work is distributed under the terms of a permission notice
  36. identical to this one.
  37.  
  38.    Permission is granted to copy and distribute translations of this
  39. manual into another language, under the above conditions for modified
  40. versions, except that the section entitled "GNU General Public License"
  41. may be included in a translation approved by the Free Software
  42. Foundation instead of in the original English.
  43.  
  44. 
  45. File: lispref.info,  Node: Syntax Basics,  Next: Syntax Descriptors,  Up: Syntax Tables
  46.  
  47. Syntax Table Concepts
  48. =====================
  49.  
  50.    A "syntax table" provides Emacs with the information that determines
  51. the syntactic use of each character in a buffer.  This information is
  52. used by the parsing commands, the complex movement commands, and others
  53. to determine where words, symbols, and other syntactic constructs begin
  54. and end.  The current syntax table controls the meaning of the word
  55. motion functions (*note Word Motion::.) and the list motion functions
  56. (*note List Motion::.) as well as the functions in this chapter.
  57.  
  58.    A syntax table is a vector of 256 elements; it contains one entry for
  59. each of the 256 possible characters in an 8-bit byte.  Each element is
  60. an integer that encodes the syntax of the character in question.
  61.  
  62.    Syntax tables are used only for moving across text, not for the Emacs
  63. Lisp reader.  Emacs Lisp uses built-in syntactic rules when reading Lisp
  64. expressions, and these rules cannot be changed.
  65.  
  66.    Each buffer has its own major mode, and each major mode has its own
  67. idea of the syntactic class of various characters.  For example, in Lisp
  68. mode, the character `;' begins a comment, but in C mode, it terminates
  69. a statement.  To support these variations, XEmacs makes the choice of
  70. syntax table local to each buffer.  Typically, each major mode has its
  71. own syntax table and installs that table in each buffer that uses that
  72. mode.  Changing this table alters the syntax in all those buffers as
  73. well as in any buffers subsequently put in that mode.  Occasionally
  74. several similar modes share one syntax table.  *Note Example Major
  75. Modes::, for an example of how to set up a syntax table.
  76.  
  77.    A syntax table can inherit the data for some characters from the
  78. standard syntax table, while specifying other characters itself.  The
  79. "inherit" syntax class means "inherit this character's syntax from the
  80. standard syntax table."  Most major modes' syntax tables inherit the
  81. syntax of character codes 0 through 31 and 128 through 255.  This is
  82. useful with character sets such as ISO Latin-1 that have additional
  83. alphabetic characters in the range 128 to 255.  Just changing the
  84. standard syntax for these characters affects all major modes.
  85.  
  86.  - Function: syntax-table-p OBJECT
  87.      This function returns `t' if OBJECT is a vector of length 256
  88.      elements.  This means that the vector may be a syntax table.
  89.      However, according to this test, any vector of length 256 is
  90.      considered to be a syntax table, no matter what its contents.
  91.  
  92. 
  93. File: lispref.info,  Node: Syntax Descriptors,  Next: Syntax Table Functions,  Prev: Syntax Basics,  Up: Syntax Tables
  94.  
  95. Syntax Descriptors
  96. ==================
  97.  
  98.    This section describes the syntax classes and flags that denote the
  99. syntax of a character, and how they are represented as a "syntax
  100. descriptor", which is a Lisp string that you pass to
  101. `modify-syntax-entry' to specify the desired syntax.
  102.  
  103.    XEmacs defines a number of "syntax classes".  Each syntax table puts
  104. each character into one class.  There is no necessary relationship
  105. between the class of a character in one syntax table and its class in
  106. any other table.
  107.  
  108.    Each class is designated by a mnemonic character, which serves as the
  109. name of the class when you need to specify a class.  Usually the
  110. designator character is one that is frequently in that class; however,
  111. its meaning as a designator is unvarying and independent of what syntax
  112. that character currently has.
  113.  
  114.    A syntax descriptor is a Lisp string that specifies a syntax class, a
  115. matching character (used only for the parenthesis classes) and flags.
  116. The first character is the designator for a syntax class.  The second
  117. character is the character to match; if it is unused, put a space there.
  118. Then come the characters for any desired flags.  If no matching
  119. character or flags are needed, one character is sufficient.
  120.  
  121.    For example, the descriptor for the character `*' in C mode is
  122. `. 23' (i.e., punctuation, matching character slot unused, second
  123. character of a comment-starter, first character of an comment-ender),
  124. and the entry for `/' is `. 14' (i.e., punctuation, matching character
  125. slot unused, first character of a comment-starter, second character of
  126. a comment-ender).
  127.  
  128. * Menu:
  129.  
  130. * Syntax Class Table::      Table of syntax classes.
  131. * Syntax Flags::            Additional flags each character can have.
  132.  
  133. 
  134. File: lispref.info,  Node: Syntax Class Table,  Next: Syntax Flags,  Up: Syntax Descriptors
  135.  
  136. Table of Syntax Classes
  137. -----------------------
  138.  
  139.    Here is a table of syntax classes, the characters that stand for
  140. them, their meanings, and examples of their use.
  141.  
  142.  - Syntax class: whitespace character
  143.      "Whitespace characters" (designated with ` ' or `-') separate
  144.      symbols and words from each other.  Typically, whitespace
  145.      characters have no other syntactic significance, and multiple
  146.      whitespace characters are syntactically equivalent to a single
  147.      one.  Space, tab, newline and formfeed are almost always
  148.      classified as whitespace.
  149.  
  150.  - Syntax class: word constituent
  151.      "Word constituents" (designated with `w') are parts of normal
  152.      English words and are typically used in variable and command names
  153.      in programs.  All upper- and lower-case letters, and the digits,
  154.      are typically word constituents.
  155.  
  156.  - Syntax class: symbol constituent
  157.      "Symbol constituents" (designated with `_') are the extra
  158.      characters that are used in variable and command names along with
  159.      word constituents.  For example, the symbol constituents class is
  160.      used in Lisp mode to indicate that certain characters may be part
  161.      of symbol names even though they are not part of English words.
  162.      These characters are `$&*+-_<>'.  In standard C, the only
  163.      non-word-constituent character that is valid in symbols is
  164.      underscore (`_').
  165.  
  166.  - Syntax class: punctuation character
  167.      "Punctuation characters" (`.') are those characters that are used
  168.      as punctuation in English, or are used in some way in a programming
  169.      language to separate symbols from one another.  Most programming
  170.      language modes, including Emacs Lisp mode, have no characters in
  171.      this class since the few characters that are not symbol or word
  172.      constituents all have other uses.
  173.  
  174.  - Syntax class: open parenthesis character
  175.  - Syntax class: close parenthesis character
  176.      Open and close "parenthesis characters" are characters used in
  177.      dissimilar pairs to surround sentences or expressions.  Such a
  178.      grouping is begun with an open parenthesis character and
  179.      terminated with a close.  Each open parenthesis character matches
  180.      a particular close parenthesis character, and vice versa.
  181.      Normally, XEmacs indicates momentarily the matching open
  182.      parenthesis when you insert a close parenthesis.  *Note Blinking::.
  183.  
  184.      The class of open parentheses is designated with `(', and that of
  185.      close parentheses with `)'.
  186.  
  187.      In English text, and in C code, the parenthesis pairs are `()',
  188.      `[]', and `{}'.  In Emacs Lisp, the delimiters for lists and
  189.      vectors (`()' and `[]') are classified as parenthesis characters.
  190.  
  191.  - Syntax class: string quote
  192.      "String quote characters" (designated with `"') are used in many
  193.      languages, including Lisp and C, to delimit string constants.  The
  194.      same string quote character appears at the beginning and the end
  195.      of a string.  Such quoted strings do not nest.
  196.  
  197.      The parsing facilities of XEmacs consider a string as a single
  198.      token.  The usual syntactic meanings of the characters in the
  199.      string are suppressed.
  200.  
  201.      The Lisp modes have two string quote characters: double-quote (`"')
  202.      and vertical bar (`|').  `|' is not used in Emacs Lisp, but it is
  203.      used in Common Lisp.  C also has two string quote characters:
  204.      double-quote for strings, and single-quote (`'') for character
  205.      constants.
  206.  
  207.      English text has no string quote characters because English is not
  208.      a programming language.  Although quotation marks are used in
  209.      English, we do not want them to turn off the usual syntactic
  210.      properties of other characters in the quotation.
  211.  
  212.  - Syntax class: escape
  213.      An "escape character" (designated with `\') starts an escape
  214.      sequence such as is used in C string and character constants.  The
  215.      character `\' belongs to this class in both C and Lisp.  (In C, it
  216.      is used thus only inside strings, but it turns out to cause no
  217.      trouble to treat it this way throughout C code.)
  218.  
  219.      Characters in this class count as part of words if
  220.      `words-include-escapes' is non-`nil'.  *Note Word Motion::.
  221.  
  222.  - Syntax class: character quote
  223.      A "character quote character" (designated with `/') quotes the
  224.      following character so that it loses its normal syntactic meaning.
  225.      This differs from an escape character in that only the character
  226.      immediately following is ever affected.
  227.  
  228.      Characters in this class count as part of words if
  229.      `words-include-escapes' is non-`nil'.  *Note Word Motion::.
  230.  
  231.      This class is used for backslash in TeX mode.
  232.  
  233.  - Syntax class: paired delimiter
  234.      "Paired delimiter characters" (designated with `$') are like
  235.      string quote characters except that the syntactic properties of the
  236.      characters between the delimiters are not suppressed.  Only TeX
  237.      mode uses a paired delimiter presently--the `$' that both enters
  238.      and leaves math mode.
  239.  
  240.  - Syntax class: expression prefix
  241.      An "expression prefix operator" (designated with `'') is used for
  242.      syntactic operators that are part of an expression if they appear
  243.      next to one.  These characters in Lisp include the apostrophe, `''
  244.      (used for quoting), the comma, `,' (used in macros), and `#' (used
  245.      in the read syntax for certain data types).
  246.  
  247.  - Syntax class: comment starter
  248.  - Syntax class: comment ender
  249.      The "comment starter" and "comment ender" characters are used in
  250.      various languages to delimit comments.  These classes are
  251.      designated with `<' and `>', respectively.
  252.  
  253.      English text has no comment characters.  In Lisp, the semicolon
  254.      (`;') starts a comment and a newline or formfeed ends one.
  255.  
  256.  - Syntax class: inherit
  257.      This syntax class does not specify a syntax.  It says to look in
  258.      the standard syntax table to find the syntax of this character.
  259.      The designator for this syntax code is `@'.
  260.  
  261. 
  262. File: lispref.info,  Node: Syntax Flags,  Prev: Syntax Class Table,  Up: Syntax Descriptors
  263.  
  264. Syntax Flags
  265. ------------
  266.  
  267.    In addition to the classes, entries for characters in a syntax table
  268. can include flags.  There are six possible flags, represented by the
  269. characters `1', `2', `3', `4', `b' and `p'.
  270.  
  271.    All the flags except `p' are used to describe multi-character
  272. comment delimiters.  The digit flags indicate that a character can
  273. *also* be part of a comment sequence, in addition to the syntactic
  274. properties associated with its character class.  The flags are
  275. independent of the class and each other for the sake of characters such
  276. as `*' in C mode, which is a punctuation character, *and* the second
  277. character of a start-of-comment sequence (`/*'), *and* the first
  278. character of an end-of-comment sequence (`*/').
  279.  
  280.    The flags for a character C are:
  281.  
  282.    * `1' means C is the start of a two-character comment-start sequence.
  283.  
  284.    * `2' means C is the second character of such a sequence.
  285.  
  286.    * `3' means C is the start of a two-character comment-end sequence.
  287.  
  288.    * `4' means C is the second character of such a sequence.
  289.  
  290.    * `b' means that C as a comment delimiter belongs to the alternative
  291.      "b" comment style.
  292.  
  293.      Emacs supports two comment styles simultaneously in any one syntax
  294.      table.  This is for the sake of C++.  Each style of comment syntax
  295.      has its own comment-start sequence and its own comment-end
  296.      sequence.  Each comment must stick to one style or the other;
  297.      thus, if it starts with the comment-start sequence of style "b",
  298.      it must also end with the comment-end sequence of style "b".
  299.  
  300.      The two comment-start sequences must begin with the same
  301.      character; only the second character may differ.  Mark the second
  302.      character of the "b"-style comment-start sequence with the `b'
  303.      flag.
  304.  
  305.      A comment-end sequence (one or two characters) applies to the "b"
  306.      style if its first character has the `b' flag set; otherwise, it
  307.      applies to the "a" style.
  308.  
  309.      The appropriate comment syntax settings for C++ are as follows:
  310.  
  311.     `/'
  312.           `124b'
  313.  
  314.     `*'
  315.           `23'
  316.  
  317.     newline
  318.           `>b'
  319.  
  320.      This defines four comment-delimiting sequences:
  321.  
  322.     `/*'
  323.           This is a comment-start sequence for "a" style because the
  324.           second character, `*', does not have the `b' flag.
  325.  
  326.     `//'
  327.           This is a comment-start sequence for "b" style because the
  328.           second character, `/', does have the `b' flag.
  329.  
  330.     `*/'
  331.           This is a comment-end sequence for "a" style because the first
  332.           character, `*', does not have the `b' flag
  333.  
  334.     newline
  335.           This is a comment-end sequence for "b" style, because the
  336.           newline character has the `b' flag.
  337.  
  338.    * `p' identifies an additional "prefix character" for Lisp syntax.
  339.      These characters are treated as whitespace when they appear between
  340.      expressions.  When they appear within an expression, they are
  341.      handled according to their usual syntax codes.
  342.  
  343.      The function `backward-prefix-chars' moves back over these
  344.      characters, as well as over characters whose primary syntax class
  345.      is prefix (`'').  *Note Motion and Syntax::.
  346.  
  347. 
  348. File: lispref.info,  Node: Syntax Table Functions,  Next: Motion and Syntax,  Prev: Syntax Descriptors,  Up: Syntax Tables
  349.  
  350. Syntax Table Functions
  351. ======================
  352.  
  353.    In this section we describe functions for creating, accessing and
  354. altering syntax tables.
  355.  
  356.  - Function: make-syntax-table &optional TABLE
  357.      This function creates a new syntax table.  Character codes 0
  358.      through 31 and 128 through 255 are set up to inherit from the
  359.      standard syntax table.  The other character codes are set up by
  360.      copying what the standard syntax table says about them.
  361.  
  362.      Most major mode syntax tables are created in this way.
  363.  
  364.  - Function: copy-syntax-table &optional TABLE
  365.      This function constructs a copy of TABLE and returns it.  If TABLE
  366.      is not supplied (or is `nil'), it returns a copy of the current
  367.      syntax table.  Otherwise, an error is signaled if TABLE is not a
  368.      syntax table.
  369.  
  370.  - Command: modify-syntax-entry CHAR SYNTAX-DESCRIPTOR &optional TABLE
  371.      This function sets the syntax entry for CHAR according to
  372.      SYNTAX-DESCRIPTOR.  The syntax is changed only for TABLE, which
  373.      defaults to the current buffer's syntax table, and not in any
  374.      other syntax table.  The argument SYNTAX-DESCRIPTOR specifies the
  375.      desired syntax; this is a string beginning with a class designator
  376.      character, and optionally containing a matching character and
  377.      flags as well.  *Note Syntax Descriptors::.
  378.  
  379.      This function always returns `nil'.  The old syntax information in
  380.      the table for this character is discarded.
  381.  
  382.      An error is signaled if the first character of the syntax
  383.      descriptor is not one of the twelve syntax class designator
  384.      characters.  An error is also signaled if CHAR is not a character.
  385.  
  386.      Examples:
  387.  
  388.           ;; Put the space character in class whitespace.
  389.           (modify-syntax-entry ?\  " ")
  390.                => nil
  391.           
  392.           ;; Make `$' an open parenthesis character,
  393.           ;;   with `^' as its matching close.
  394.           (modify-syntax-entry ?$ "(^")
  395.                => nil
  396.           
  397.           ;; Make `^' a close parenthesis character,
  398.           ;;   with `$' as its matching open.
  399.           (modify-syntax-entry ?^ ")$")
  400.                => nil
  401.           
  402.           ;; Make `/' a punctuation character,
  403.           ;;   the first character of a start-comment sequence,
  404.           ;;   and the second character of an end-comment sequence.
  405.           ;;   This is used in C mode.
  406.           (modify-syntax-entry ?/ ". 14")
  407.                => nil
  408.  
  409.  - Function: char-syntax CHARACTER
  410.      This function returns the syntax class of CHARACTER, represented
  411.      by its mnemonic designator character.  This *only* returns the
  412.      class, not any matching parenthesis or flags.
  413.  
  414.      An error is signaled if CHAR is not a character.
  415.  
  416.      The following examples apply to C mode.  The first example shows
  417.      that the syntax class of space is whitespace (represented by a
  418.      space).  The second example shows that the syntax of `/' is
  419.      punctuation.  This does not show the fact that it is also part of
  420.      comment-start and -end sequences.  The third example shows that
  421.      open parenthesis is in the class of open parentheses.  This does
  422.      not show the fact that it has a matching character, `)'.
  423.  
  424.           (char-to-string (char-syntax ?\ ))
  425.                => " "
  426.           
  427.           (char-to-string (char-syntax ?/))
  428.                => "."
  429.           
  430.           (char-to-string (char-syntax ?\())
  431.                => "("
  432.  
  433.  - Function: set-syntax-table TABLE &optional BUFFER
  434.      This function makes TABLE the syntax table for BUFFER, which
  435.      defaults to the current buffer if omitted.  It returns TABLE.
  436.  
  437.  - Function: syntax-table &optional BUFFER
  438.      This function returns the syntax table for BUFFER, which defaults
  439.      to the current buffer if omitted.
  440.  
  441. 
  442. File: lispref.info,  Node: Motion and Syntax,  Next: Parsing Expressions,  Prev: Syntax Table Functions,  Up: Syntax Tables
  443.  
  444. Motion and Syntax
  445. =================
  446.  
  447.    This section describes functions for moving across characters in
  448. certain syntax classes.  None of these functions exists in Emacs
  449. version 18 or earlier.
  450.  
  451.  - Function: skip-syntax-forward SYNTAXES &optional LIMIT BUFFER
  452.      This function moves point forward across characters having syntax
  453.      classes mentioned in SYNTAXES.  It stops when it encounters the
  454.      end of the buffer, or position LIMIT (if specified), or a
  455.      character it is not supposed to skip.  Optional argument BUFFER
  456.      defaults to the current buffer if omitted.
  457.  
  458.  - Function: skip-syntax-backward SYNTAXES &optional LIMIT BUFFER
  459.      This function moves point backward across characters whose syntax
  460.      classes are mentioned in SYNTAXES.  It stops when it encounters
  461.      the beginning of the buffer, or position LIMIT (if specified), or a
  462.      character it is not supposed to skip.  Optional argument BUFFER
  463.      defaults to the current buffer if omitted.
  464.  
  465.  
  466.  - Function: backward-prefix-chars &optional BUFFER
  467.      This function moves point backward over any number of characters
  468.      with expression prefix syntax.  This includes both characters in
  469.      the expression prefix syntax class, and characters with the `p'
  470.      flag.  Optional argument BUFFER defaults to the current buffer if
  471.      omitted.
  472.  
  473. 
  474. File: lispref.info,  Node: Parsing Expressions,  Next: Standard Syntax Tables,  Prev: Motion and Syntax,  Up: Syntax Tables
  475.  
  476. Parsing Balanced Expressions
  477. ============================
  478.  
  479.    Here are several functions for parsing and scanning balanced
  480. expressions, also known as "sexps", in which parentheses match in
  481. pairs.  The syntax table controls the interpretation of characters, so
  482. these functions can be used for Lisp expressions when in Lisp mode and
  483. for C expressions when in C mode.  *Note List Motion::, for convenient
  484. higher-level functions for moving over balanced expressions.
  485.  
  486.  - Function: parse-partial-sexp START LIMIT &optional TARGET-DEPTH
  487.           STOP-BEFORE STATE STOP-COMMENT BUFFER
  488.      This function parses a sexp in the current buffer starting at
  489.      START, not scanning past LIMIT.  It stops at position LIMIT or
  490.      when certain criteria described below are met, and sets point to
  491.      the location where parsing stops.  It returns a value describing
  492.      the status of the parse at the point where it stops.
  493.  
  494.      If STATE is `nil', START is assumed to be at the top level of
  495.      parenthesis structure, such as the beginning of a function
  496.      definition.  Alternatively, you might wish to resume parsing in the
  497.      middle of the structure.  To do this, you must provide a STATE
  498.      argument that describes the initial status of parsing.
  499.  
  500.      If the third argument TARGET-DEPTH is non-`nil', parsing stops if
  501.      the depth in parentheses becomes equal to TARGET-DEPTH.  The depth
  502.      starts at 0, or at whatever is given in STATE.
  503.  
  504.      If the fourth argument STOP-BEFORE is non-`nil', parsing stops
  505.      when it comes to any character that starts a sexp.  If
  506.      STOP-COMMENT is non-`nil', parsing stops when it comes to the
  507.      start of a comment.
  508.  
  509.      The fifth argument STATE is an eight-element list of the same form
  510.      as the value of this function, described below.  The return value
  511.      of one call may be used to initialize the state of the parse on
  512.      another call to `parse-partial-sexp'.
  513.  
  514.      The result is a list of eight elements describing the final state
  515.      of the parse:
  516.  
  517.        0. The depth in parentheses, counting from 0.
  518.  
  519.        1. The character position of the start of the innermost
  520.           parenthetical grouping containing the stopping point; `nil'
  521.           if none.
  522.  
  523.        2. The character position of the start of the last complete
  524.           subexpression terminated; `nil' if none.
  525.  
  526.        3. Non-`nil' if inside a string.  More precisely, this is the
  527.           character that will terminate the string.
  528.  
  529.        4. `t' if inside a comment (of either style).
  530.  
  531.        5. `t' if point is just after a quote character.
  532.  
  533.        6. The minimum parenthesis depth encountered during this scan.
  534.  
  535.        7. `t' if inside a comment of style "b".
  536.  
  537.      Elements 0, 3, 4, 5 and 7 are significant in the argument STATE.
  538.  
  539.      This function is most often used to compute indentation for
  540.      languages that have nested parentheses.
  541.  
  542.  - Function: scan-lists FROM COUNT DEPTH &optional BUFFER NOERROR
  543.      This function scans forward COUNT balanced parenthetical groupings
  544.      from character number FROM.  It returns the character position
  545.      where the scan stops.
  546.  
  547.      If DEPTH is nonzero, parenthesis depth counting begins from that
  548.      value.  The only candidates for stopping are places where the
  549.      depth in parentheses becomes zero; `scan-lists' counts COUNT such
  550.      places and then stops.  Thus, a positive value for DEPTH means go
  551.      out DEPTH levels of parenthesis.
  552.  
  553.      Scanning ignores comments if `parse-sexp-ignore-comments' is
  554.      non-`nil'.
  555.  
  556.      If the scan reaches the beginning or end of the buffer (or its
  557.      accessible portion), and the depth is not zero, an error is
  558.      signaled.  If the depth is zero but the count is not used up,
  559.      `nil' is returned.
  560.  
  561.      If optional arg BUFFER is non-`nil', scanning occurs in that
  562.      buffer instead of in the current buffer.
  563.  
  564.      If optional arg NOERROR is non-`nil', `scan-lists' will return
  565.      `nil' instead of signalling an error.
  566.  
  567.  - Function: scan-sexps FROM COUNT &optional BUFFER NOERROR
  568.      This function scans forward COUNT sexps from character position
  569.      FROM.  It returns the character position where the scan stops.
  570.  
  571.      Scanning ignores comments if `parse-sexp-ignore-comments' is
  572.      non-`nil'.
  573.  
  574.      If the scan reaches the beginning or end of (the accessible part
  575.      of) the buffer in the middle of a parenthetical grouping, an error
  576.      is signaled.  If it reaches the beginning or end between groupings
  577.      but before count is used up, `nil' is returned.
  578.  
  579.      If optional arg BUFFER is non-`nil', scanning occurs in that
  580.      buffer instead of in the current buffer.
  581.  
  582.      If optional arg NOERROR is non-`nil', `scan-sexps' will return nil
  583.      instead of signalling an error.
  584.  
  585.  - Variable: parse-sexp-ignore-comments
  586.      If the value is non-`nil', then comments are treated as whitespace
  587.      by the functions in this section and by `forward-sexp'.
  588.  
  589.      In older Emacs versions, this feature worked only when the comment
  590.      terminator is something like `*/', and appears only to end a
  591.      comment.  In languages where newlines terminate comments, it was
  592.      necessary make this variable `nil', since not every newline is the
  593.      end of a comment.  This limitation no longer exists.
  594.  
  595.    You can use `forward-comment' to move forward or backward over one
  596. comment or several comments.
  597.  
  598.  - Function: forward-comment COUNT &optional BUFFER
  599.      This function moves point forward across COUNT comments (backward,
  600.      if COUNT is negative).  If it finds anything other than a comment
  601.      or whitespace, it stops, leaving point at the place where it
  602.      stopped.  It also stops after satisfying COUNT.
  603.  
  604.      Optional argument BUFFER defaults to the current buffer.
  605.  
  606.    To move forward over all comments and whitespace following point, use
  607. `(forward-comment (buffer-size))'.  `(buffer-size)' is a good argument
  608. to use, because the number of comments in the buffer cannot exceed that
  609. many.
  610.  
  611. 
  612. File: lispref.info,  Node: Standard Syntax Tables,  Next: Syntax Table Internals,  Prev: Parsing Expressions,  Up: Syntax Tables
  613.  
  614. Some Standard Syntax Tables
  615. ===========================
  616.  
  617.    Most of the major modes in XEmacs have their own syntax tables.  Here
  618. are several of them:
  619.  
  620.  - Function: standard-syntax-table
  621.      This function returns the standard syntax table, which is the
  622.      syntax table used in Fundamental mode.
  623.  
  624.  - Variable: text-mode-syntax-table
  625.      The value of this variable is the syntax table used in Text mode.
  626.  
  627.  - Variable: c-mode-syntax-table
  628.      The value of this variable is the syntax table for C-mode buffers.
  629.  
  630.  - Variable: emacs-lisp-mode-syntax-table
  631.      The value of this variable is the syntax table used in Emacs Lisp
  632.      mode by editing commands.  (It has no effect on the Lisp `read'
  633.      function.)
  634.  
  635. 
  636. File: lispref.info,  Node: Syntax Table Internals,  Prev: Standard Syntax Tables,  Up: Syntax Tables
  637.  
  638. Syntax Table Internals
  639. ======================
  640.  
  641.    Each element of a syntax table is an integer that encodes the syntax
  642. of one character: the syntax class, possible matching character, and
  643. flags.  Lisp programs don't usually work with the elements directly; the
  644. Lisp-level syntax table functions usually work with syntax descriptors
  645. (*note Syntax Descriptors::.).
  646.  
  647.    The low 8 bits of each element of a syntax table indicate the syntax
  648. class.
  649.  
  650. Integer
  651.      Class
  652.  
  653. 0
  654.      whitespace
  655.  
  656. 1
  657.      punctuation
  658.  
  659. 2
  660.      word
  661.  
  662. 3
  663.      symbol
  664.  
  665. 4
  666.      open parenthesis
  667.  
  668. 5
  669.      close parenthesis
  670.  
  671. 6
  672.      expression prefix
  673.  
  674. 7
  675.      string quote
  676.  
  677. 8
  678.      paired delimiter
  679.  
  680. 9
  681.      escape
  682.  
  683. 10
  684.      character quote
  685.  
  686. 11
  687.      comment-start
  688.  
  689. 12
  690.      comment-end
  691.  
  692. 13
  693.      inherit
  694.  
  695.    The next 8 bits are the matching opposite parenthesis (if the
  696. character has parenthesis syntax); otherwise, they are not meaningful.
  697. The next 6 bits are the flags.
  698.  
  699. 
  700. File: lispref.info,  Node: Abbrevs,  Next: Extents,  Prev: Syntax Tables,  Up: Top
  701.  
  702. Abbrevs And Abbrev Expansion
  703. ****************************
  704.  
  705.    An abbreviation or "abbrev" is a string of characters that may be
  706. expanded to a longer string.  The user can insert the abbrev string and
  707. find it replaced automatically with the expansion of the abbrev.  This
  708. saves typing.
  709.  
  710.    The set of abbrevs currently in effect is recorded in an "abbrev
  711. table".  Each buffer has a local abbrev table, but normally all buffers
  712. in the same major mode share one abbrev table.  There is also a global
  713. abbrev table.  Normally both are used.
  714.  
  715.    An abbrev table is represented as an obarray containing a symbol for
  716. each abbreviation.  The symbol's name is the abbreviation; its value is
  717. the expansion; its function definition is the hook function to do the
  718. expansion (*note Defining Abbrevs::.); its property list cell contains
  719. the use count, the number of times the abbreviation has been expanded.
  720. Because these symbols are not interned in the usual obarray, they will
  721. never appear as the result of reading a Lisp expression; in fact,
  722. normally they are never used except by the code that handles abbrevs.
  723. Therefore, it is safe to use them in an extremely nonstandard way.
  724. *Note Creating Symbols::.
  725.  
  726.    For the user-level commands for abbrevs, see *Note Abbrev Mode:
  727. (emacs)Abbrevs.
  728.  
  729. * Menu:
  730.  
  731. * Abbrev Mode::                 Setting up XEmacs for abbreviation.
  732. * Tables: Abbrev Tables.        Creating and working with abbrev tables.
  733. * Defining Abbrevs::            Specifying abbreviations and their expansions.
  734. * Files: Abbrev Files.          Saving abbrevs in files.
  735. * Expansion: Abbrev Expansion.  Controlling expansion; expansion subroutines.
  736. * Standard Abbrev Tables::      Abbrev tables used by various major modes.
  737.  
  738. 
  739. File: lispref.info,  Node: Abbrev Mode,  Next: Abbrev Tables,  Up: Abbrevs
  740.  
  741. Setting Up Abbrev Mode
  742. ======================
  743.  
  744.    Abbrev mode is a minor mode controlled by the value of the variable
  745. `abbrev-mode'.
  746.  
  747.  - Variable: abbrev-mode
  748.      A non-`nil' value of this variable turns on the automatic expansion
  749.      of abbrevs when their abbreviations are inserted into a buffer.
  750.      If the value is `nil', abbrevs may be defined, but they are not
  751.      expanded automatically.
  752.  
  753.      This variable automatically becomes local when set in any fashion.
  754.  
  755.  - Variable: default-abbrev-mode
  756.      This is the value of `abbrev-mode' for buffers that do not
  757.      override it.  This is the same as `(default-value 'abbrev-mode)'.
  758.  
  759. 
  760. File: lispref.info,  Node: Abbrev Tables,  Next: Defining Abbrevs,  Prev: Abbrev Mode,  Up: Abbrevs
  761.  
  762. Abbrev Tables
  763. =============
  764.  
  765.    This section describes how to create and manipulate abbrev tables.
  766.  
  767.  - Function: make-abbrev-table
  768.      This function creates and returns a new, empty abbrev table--an
  769.      obarray containing no symbols.  It is a vector filled with zeros.
  770.  
  771.  - Function: clear-abbrev-table TABLE
  772.      This function undefines all the abbrevs in abbrev table TABLE,
  773.      leaving it empty.  The function returns `nil'.
  774.  
  775.  - Function: define-abbrev-table TABNAME DEFINITIONS
  776.      This function defines TABNAME (a symbol) as an abbrev table name,
  777.      i.e., as a variable whose value is an abbrev table.  It defines
  778.      abbrevs in the table according to DEFINITIONS, a list of elements
  779.      of the form `(ABBREVNAME EXPANSION HOOK USECOUNT)'.  The value is
  780.      always `nil'.
  781.  
  782.  - Variable: abbrev-table-name-list
  783.      This is a list of symbols whose values are abbrev tables.
  784.      `define-abbrev-table' adds the new abbrev table name to this list.
  785.  
  786.  - Function: insert-abbrev-table-description NAME &optional HUMAN
  787.      This function inserts before point a description of the abbrev
  788.      table named NAME.  The argument NAME is a symbol whose value is an
  789.      abbrev table.  The value is always `nil'.
  790.  
  791.      If HUMAN is non-`nil', the description is human-oriented.
  792.      Otherwise the description is a Lisp expression--a call to
  793.      `define-abbrev-table' that would define NAME exactly as it is
  794.      currently defined.
  795.  
  796. 
  797. File: lispref.info,  Node: Defining Abbrevs,  Next: Abbrev Files,  Prev: Abbrev Tables,  Up: Abbrevs
  798.  
  799. Defining Abbrevs
  800. ================
  801.  
  802.    These functions define an abbrev in a specified abbrev table.
  803. `define-abbrev' is the low-level basic function, while `add-abbrev' is
  804. used by commands that ask for information from the user.
  805.  
  806.  - Function: add-abbrev TABLE TYPE ARG
  807.      This function adds an abbreviation to abbrev table TABLE based on
  808.      information from the user.  The argument TYPE is a string
  809.      describing in English the kind of abbrev this will be (typically,
  810.      `"global"' or `"mode-specific"'); this is used in prompting the
  811.      user.  The argument ARG is the number of words in the expansion.
  812.  
  813.      The return value is the symbol that internally represents the new
  814.      abbrev, or `nil' if the user declines to confirm redefining an
  815.      existing abbrev.
  816.  
  817.  - Function: define-abbrev TABLE NAME EXPANSION HOOK
  818.      This function defines an abbrev in TABLE named NAME, to expand to
  819.      EXPANSION, and call HOOK.  The return value is an uninterned
  820.      symbol that represents the abbrev inside XEmacs; its name is NAME.
  821.  
  822.      The argument NAME should be a string.  The argument EXPANSION
  823.      should be a string, or `nil' to undefine the abbrev.
  824.  
  825.      The argument HOOK is a function or `nil'.  If HOOK is non-`nil',
  826.      then it is called with no arguments after the abbrev is replaced
  827.      with EXPANSION; point is located at the end of EXPANSION when HOOK
  828.      is called.
  829.  
  830.      The use count of the abbrev is initialized to zero.
  831.  
  832.  - User Option: only-global-abbrevs
  833.      If this variable is non-`nil', it means that the user plans to use
  834.      global abbrevs only.  This tells the commands that define
  835.      mode-specific abbrevs to define global ones instead.  This
  836.      variable does not alter the behavior of the functions in this
  837.      section; it is examined by their callers.
  838.  
  839. 
  840. File: lispref.info,  Node: Abbrev Files,  Next: Abbrev Expansion,  Prev: Defining Abbrevs,  Up: Abbrevs
  841.  
  842. Saving Abbrevs in Files
  843. =======================
  844.  
  845.    A file of saved abbrev definitions is actually a file of Lisp code.
  846. The abbrevs are saved in the form of a Lisp program to define the same
  847. abbrev tables with the same contents.  Therefore, you can load the file
  848. with `load' (*note How Programs Do Loading::.).  However, the function
  849. `quietly-read-abbrev-file' is provided as a more convenient interface.
  850.  
  851.    User-level facilities such as `save-some-buffers' can save abbrevs
  852. in a file automatically, under the control of variables described here.
  853.  
  854.  - User Option: abbrev-file-name
  855.      This is the default file name for reading and saving abbrevs.
  856.  
  857.  - Function: quietly-read-abbrev-file FILENAME
  858.      This function reads abbrev definitions from a file named FILENAME,
  859.      previously written with `write-abbrev-file'.  If FILENAME is
  860.      `nil', the file specified in `abbrev-file-name' is used.
  861.      `save-abbrevs' is set to `t' so that changes will be saved.
  862.  
  863.      This function does not display any messages.  It returns `nil'.
  864.  
  865.  - User Option: save-abbrevs
  866.      A non-`nil' value for `save-abbrev' means that XEmacs should save
  867.      abbrevs when files are saved.  `abbrev-file-name' specifies the
  868.      file to save the abbrevs in.
  869.  
  870.  - Variable: abbrevs-changed
  871.      This variable is set non-`nil' by defining or altering any
  872.      abbrevs.  This serves as a flag for various XEmacs commands to
  873.      offer to save your abbrevs.
  874.  
  875.  - Command: write-abbrev-file FILENAME
  876.      Save all abbrev definitions, in all abbrev tables, in the file
  877.      FILENAME, in the form of a Lisp program that when loaded will
  878.      define the same abbrevs.  This function returns `nil'.
  879.  
  880. 
  881. File: lispref.info,  Node: Abbrev Expansion,  Next: Standard Abbrev Tables,  Prev: Abbrev Files,  Up: Abbrevs
  882.  
  883. Looking Up and Expanding Abbreviations
  884. ======================================
  885.  
  886.    Abbrevs are usually expanded by commands for interactive use,
  887. including `self-insert-command'.  This section describes the
  888. subroutines used in writing such functions, as well as the variables
  889. they use for communication.
  890.  
  891.  - Function: abbrev-symbol ABBREV &optional TABLE
  892.      This function returns the symbol representing the abbrev named
  893.      ABBREV.  The value returned is `nil' if that abbrev is not
  894.      defined.  The optional second argument TABLE is the abbrev table
  895.      to look it up in.  If TABLE is `nil', this function tries first
  896.      the current buffer's local abbrev table, and second the global
  897.      abbrev table.
  898.  
  899.  - Function: abbrev-expansion ABBREV &optional TABLE
  900.      This function returns the string that ABBREV would expand into (as
  901.      defined by the abbrev tables used for the current buffer).  The
  902.      optional argument TABLE specifies the abbrev table to use, as in
  903.      `abbrev-symbol'.
  904.  
  905.  - Command: expand-abbrev
  906.      This command expands the abbrev before point, if any.  If point
  907.      does not follow an abbrev, this command does nothing.  The command
  908.      returns `t' if it did expansion, `nil' otherwise.
  909.  
  910.  - Command: abbrev-prefix-mark &optional ARG
  911.      Mark current point as the beginning of an abbrev.  The next call to
  912.      `expand-abbrev' will use the text from here to point (where it is
  913.      then) as the abbrev to expand, rather than using the previous word
  914.      as usual.
  915.  
  916.  - User Option: abbrev-all-caps
  917.      When this is set non-`nil', an abbrev entered entirely in upper
  918.      case is expanded using all upper case.  Otherwise, an abbrev
  919.      entered entirely in upper case is expanded by capitalizing each
  920.      word of the expansion.
  921.  
  922.  - Variable: abbrev-start-location
  923.      This is the buffer position for `expand-abbrev' to use as the start
  924.      of the next abbrev to be expanded.  (`nil' means use the word
  925.      before point instead.)  `abbrev-start-location' is set to `nil'
  926.      each time `expand-abbrev' is called.  This variable is also set by
  927.      `abbrev-prefix-mark'.
  928.  
  929.  - Variable: abbrev-start-location-buffer
  930.      The value of this variable is the buffer for which
  931.      `abbrev-start-location' has been set.  Trying to expand an abbrev
  932.      in any other buffer clears `abbrev-start-location'.  This variable
  933.      is set by `abbrev-prefix-mark'.
  934.  
  935.  - Variable: last-abbrev
  936.      This is the `abbrev-symbol' of the last abbrev expanded.  This
  937.      information is left by `expand-abbrev' for the sake of the
  938.      `unexpand-abbrev' command.
  939.  
  940.  - Variable: last-abbrev-location
  941.      This is the location of the last abbrev expanded.  This contains
  942.      information left by `expand-abbrev' for the sake of the
  943.      `unexpand-abbrev' command.
  944.  
  945.  - Variable: last-abbrev-text
  946.      This is the exact expansion text of the last abbrev expanded,
  947.      after case conversion (if any).  Its value is `nil' if the abbrev
  948.      has already been unexpanded.  This contains information left by
  949.      `expand-abbrev' for the sake of the `unexpand-abbrev' command.
  950.  
  951.  - Variable: pre-abbrev-expand-hook
  952.      This is a normal hook whose functions are executed, in sequence,
  953.      just before any expansion of an abbrev.  *Note Hooks::.  Since it
  954.      is a normal hook, the hook functions receive no arguments.
  955.      However, they can find the abbrev to be expanded by looking in the
  956.      buffer before point.
  957.  
  958.    The following sample code shows a simple use of
  959. `pre-abbrev-expand-hook'.  If the user terminates an abbrev with a
  960. punctuation character, the hook function asks for confirmation.  Thus,
  961. this hook allows the user to decide whether to expand the abbrev, and
  962. aborts expansion if it is not confirmed.
  963.  
  964.      (add-hook 'pre-abbrev-expand-hook 'query-if-not-space)
  965.      
  966.      ;; This is the function invoked by `pre-abbrev-expand-hook'.
  967.      
  968.      ;; If the user terminated the abbrev with a space, the function does
  969.      ;; nothing (that is, it returns so that the abbrev can expand).  If the
  970.      ;; user entered some other character, this function asks whether
  971.      ;; expansion should continue.
  972.      
  973.      ;; If the user answers the prompt with `y', the function returns
  974.      ;; `nil' (because of the `not' function), but that is
  975.      ;; acceptable; the return value has no effect on expansion.
  976.      
  977.      (defun query-if-not-space ()
  978.        (if (/= ?\  (preceding-char))
  979.            (if (not (y-or-n-p "Do you want to expand this abbrev? "))
  980.                (error "Not expanding this abbrev"))))
  981.  
  982. 
  983. File: lispref.info,  Node: Standard Abbrev Tables,  Prev: Abbrev Expansion,  Up: Abbrevs
  984.  
  985. Standard Abbrev Tables
  986. ======================
  987.  
  988.    Here we list the variables that hold the abbrev tables for the
  989. preloaded major modes of XEmacs.
  990.  
  991.  - Variable: global-abbrev-table
  992.      This is the abbrev table for mode-independent abbrevs.  The abbrevs
  993.      defined in it apply to all buffers.  Each buffer may also have a
  994.      local abbrev table, whose abbrev definitions take precedence over
  995.      those in the global table.
  996.  
  997.  - Variable: local-abbrev-table
  998.      The value of this buffer-local variable is the (mode-specific)
  999.      abbreviation table of the current buffer.
  1000.  
  1001.  - Variable: fundamental-mode-abbrev-table
  1002.      This is the local abbrev table used in Fundamental mode; in other
  1003.      words, it is the local abbrev table in all buffers in Fundamental
  1004.      mode.
  1005.  
  1006.  - Variable: text-mode-abbrev-table
  1007.      This is the local abbrev table used in Text mode.
  1008.  
  1009.  - Variable: c-mode-abbrev-table
  1010.      This is the local abbrev table used in C mode.
  1011.  
  1012.  - Variable: lisp-mode-abbrev-table
  1013.      This is the local abbrev table used in Lisp mode and Emacs Lisp
  1014.      mode.
  1015.  
  1016. 
  1017. File: lispref.info,  Node: Extents,  Next: Specifiers,  Prev: Abbrevs,  Up: Top
  1018.  
  1019. Extents
  1020. *******
  1021.  
  1022.    An "extent" is a region of text (a start position and an end
  1023. position) that is displayed in a particular face and can have certain
  1024. other properties such as being read-only.  Extents can overlap each
  1025. other.  XEmacs efficiently handles buffers with large numbers of
  1026. extents in them.
  1027.  
  1028.  - Function: extentp OBJECT
  1029.      This returns `t' if OBJECT is an extent.
  1030.  
  1031. * Menu:
  1032.  
  1033. * Intro to Extents::       Extents are regions over a buffer.
  1034. * Creating and Modifying Extents::
  1035.                Basic extent functions.
  1036. * Extent Endpoints::       Accessing and setting the bounds of an extent.
  1037. * Finding Extents::       Determining which extents are in a buffer.
  1038. * Extent Properties::       Extents have built-in and user-definable properties.
  1039. * Detached Extents::       Extents that are not in a buffer.
  1040. * Duplicable Extents::       Extents can be marked to be copied into strings.
  1041. * Extent Replicas::       Representation of extents copied into strings.
  1042. * Extents and Events::       Extents can interact with the keyboard and mouse.
  1043. * Atomic Extents::       Treating a block of text as a single entity.
  1044.  
  1045. 
  1046. File: lispref.info,  Node: Intro to Extents,  Next: Creating and Modifying Extents,  Up: Extents
  1047.  
  1048. Introduction to Extents
  1049. =======================
  1050.  
  1051.    An extent is a region of text within a buffer that has certain
  1052. properties associated with it.  The properties of an extent primarily
  1053. affect the way the text contained in the extent is displayed.  Extents
  1054. can freely overlap each other in a buffer.  Extents are invisible to
  1055. functions that merely examine the text of a buffer.
  1056.  
  1057.    An extent is logically a Lisp object consisting of a start position,
  1058. an end position, a buffer to which these positions refer, and a property
  1059. list.  As text is inserted into the buffer, the start and end positions
  1060. of the extent are automatically adjusted as necessary to keep the extent
  1061. referring to the same text in the buffer.  If text is inserted at the
  1062. boundary of an extent, the extent's `start-open' and `end-open'
  1063. properties control whether the text is included as part of the extent.
  1064. If the text bounded by an extent is deleted, the extent becomes
  1065. "detached"; its start and end positions are no longer meaningful, but
  1066. it maintains all its other properties and can later be reinserted into
  1067. a buffer.
  1068.  
  1069.    Each extent has a face associated with it, which controls the way in
  1070. which the text bounded by the extent is displayed .  If an extent's face
  1071. is `nil' or its properties are partially undefined, the corresponding
  1072. properties from the default face for the frame is used.  If two or more
  1073. extents overlap, the corresponding faces are merged to determine the
  1074. text's displayed properties.  Every extent has a "priority" that
  1075. determines which face takes precedence if the faces conflict. (If two
  1076. extents have the same priority, the one that comes later in the display
  1077. order takes precedence.  *Note display order: Extent Endpoints.)
  1078. Higher-numbered priority values correspond to a higher priority, and
  1079. priority values can be negative.  Every extent is created with a
  1080. priority of 0, but this can be changed with `set-extent-priority'.
  1081.  
  1082.    Extents can be set to respond specially to key and mouse events
  1083. within the extent.  An extent's `keymap' property controls the effect of
  1084. key and mouse strokes within the extent's text, and the `highlight'
  1085. property controls whether the extent is highlighted when the mouse moves
  1086. over it.  *Note Extents and Events::.
  1087.  
  1088.    An extent can optionally have a "start-glyph" or "end-glyph" (but
  1089. not both at one time) associated with it.  A start-glyph or end-glyph
  1090. is a pixmap or string that will be displayed either at the start or end
  1091. of an extent or in the margin of the line that the start or end of the
  1092. extent lies in, depending on the extent's layout policy.  Start-glyphs
  1093. and end-glyphs are used to implement annotations, and you should use
  1094. the annotation API functions in preference to the lower-level extent
  1095. functions.  For more information, *Note Annotations::.
  1096.  
  1097.    If an extent has its `detachable' property set, it will become
  1098. "detached" (i.e. no longer in the buffer) when all its text its
  1099. deleted.  Otherwise, it will simply shrink down to zero-length and sit
  1100. it the same place in the buffer.  By default, the `detachable' property
  1101. is set on newly-created extents.  *Note Detached Extents::.
  1102.  
  1103.    If an extent has its `duplicable' property set, it will be
  1104. remembered when a string is created from text bounded by the extent.
  1105. When the string is re-inserted into a buffer, the extent will also be
  1106. re-inserted.  This mechanism is used in the kill, yank, and undo
  1107. commands.  *Note Duplicable Extents::.
  1108.  
  1109. 
  1110. File: lispref.info,  Node: Creating and Modifying Extents,  Next: Extent Endpoints,  Prev: Intro to Extents,  Up: Extents
  1111.  
  1112. Creating and Modifying Extents
  1113. ==============================
  1114.  
  1115.  - Function: make-extent FROM TO &optional BUFFER
  1116.      This function makes an extent for the range [FROM, TO) in BUFFER.
  1117.      BUFFER defaults to the current buffer.  Insertions at point TO
  1118.      will be outside of the extent; insertions at FROM will be inside
  1119.      the extent, causing the extent to grow (*note Extent
  1120.      Endpoints::.).  This is the same way that markers behave.  The
  1121.      extent is initially detached if both FROM and TO are `nil', and in
  1122.      this case BUFFER defaults to `nil', meaning the extent is in no
  1123.      buffer (*note Detached Extents::.).
  1124.  
  1125.  - Function: delete-extent EXTENT
  1126.      This function removes EXTENT from its buffer and destroys it.
  1127.      This does not modify the buffer's text, only its display
  1128.      properties.  The extent cannot be used thereafter.  To remove an
  1129.      extent in such a way that it can be re-inserted later, use
  1130.      `detach-extent'.  *Note Detached Extents::.
  1131.  
  1132.  - Function: extent-buffer EXTENT
  1133.      This function returns the buffer of EXTENT.  If the return value
  1134.      is `nil', this means that the extent is detached; however, a
  1135.      detached extent will not necessarily return a value of `nil'.
  1136.  
  1137.  - Function: extent-live-p EXTENT
  1138.      This function returns `nil' if EXTENT is deleted, and `t'
  1139.      otherwise.
  1140.  
  1141. 
  1142. File: lispref.info,  Node: Extent Endpoints,  Next: Finding Extents,  Prev: Creating and Modifying Extents,  Up: Extents
  1143.  
  1144. Extent Endpoints
  1145. ================
  1146.  
  1147.    Every extent has a start position and an end position, and logically
  1148. affects the characters between those positions.  Normally the start and
  1149. end positions must both be valid positions in the extent's buffer.
  1150. However, both endpoints can be `nil', meaning the extent is detached.
  1151. *Note Detached Extents::.
  1152.  
  1153.    Whether the extent overlaps its endpoints is governed by its
  1154. `start-open' and `end-open' properties.  Insertion of a character at a
  1155. closed endpoint will expand the extent to include that character;
  1156. insertion at an open endpoint will not.  Similarly, functions such as
  1157. `extent-at' that scan over all extents overlapping a particular
  1158. position will include extents with a closed endpoint at that position,
  1159. but not extents with an open endpoint.
  1160.  
  1161.    Note that the `start-closed' and `end-closed' properties are
  1162. equivalent to `start-open' and `end-open' with the opposite sense.
  1163.  
  1164.    Both endpoints can be equal, in which case the extent includes no
  1165. characters but still exists in the buffer.  Zero-length extents are used
  1166. to represent annotations (*note Annotations::.) and can be used as a
  1167. more powerful form of a marker.  Deletion of all the characters in an
  1168. extent may or may not result in a zero-length extent; this depends on
  1169. the `detachable' property (*note Detached Extents::.).  Insertion at
  1170. the position of a zero-length extent expands the extent if both
  1171. endpoints are closed; goes before the extent if it has the `start-open'
  1172. property; and goes after the extent if it has the `end-open' property.
  1173. Zero-length extents with both the `start-open' and `end-open'
  1174. properties are not allowed to exist because there is no sensible way to
  1175. define their properties.  (If all the text in an extent with both
  1176. properties set is deleted and the extent is not detachable, the
  1177. `start-open' property is removed from the extent.) Deletion of a
  1178. character on a side of a zero-length extent whose corresponding
  1179. endpoint is closed causes the extent to be detached if its `detachable'
  1180. property is set; if the corresponding endpoint is open, the extent
  1181. remains in the buffer, moving as necessary.
  1182.  
  1183.    Extents are ordered within a buffer by increasing start position, and
  1184. then by decreasing end position (this is called the "display order").
  1185.  
  1186.  - Function: extent-start-position EXTENT
  1187.      This function returns the start position of EXTENT.
  1188.  
  1189.  - Function: extent-end-position EXTENT
  1190.      This function returns the end position of EXTENT.
  1191.  
  1192.  - Function: extent-length EXTENT
  1193.      This function returns the length of EXTENT in characters.  If the
  1194.      extent is detached, this returns `0'.  If the extent is not
  1195.      detached, this is equivalent to
  1196.           (- (extent-end-position EXTENT) (extent-start-position EXTENT))
  1197.  
  1198.  - Function: set-extent-endpoints EXTENT START END
  1199.      This function sets the start and end position of EXTENT to START
  1200.      and END.  If both are `nil', this is equivalent to `detach-extent'.
  1201.  
  1202.